<!DOCTYPE html>
<html xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta http-equiv="Access-Control-Allow-Origin" content="*">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="icon" href="/favicon.ico">
	<link rel="stylesheet" href="/resources/layui/css/layui.css" media="all" />
	<link rel="stylesheet" href="/resources/css/index.css" media="all" />
	<link rel="stylesheet" href="/resources/layui_ext/dtree/font/dtreefont.css" media="all" />
	<link rel="stylesheet" href="/resources/layui_ext/dtree/dtree.css" media="all" />
</head>
<body>
	<fieldset class="layui-elem-field">
  	<legend>条件选择</legend>
 	 <div class="layui-field-box">
   		<form action="" class="layui-form layui-form-pane">
   			<div class="layui-form-item" align="center">
   			<div class="layui-inline">
   				<label class="layui-form-label">客户名称</label>
    			<div class="layui-input-inline">
      				<select name ="customerid" id="customerid">
							<option value=" ">请选择客户</option>
					</select>
    			</div>
   			</div>
   			
   			<div class="layui-inline">
   				<label class="layui-form-label">商品名称</label>
   				<div class="layui-input-inline">
					<select name ="goodsid"  id="goodsid">
						<option value=" ">请选择商品</option>
					</select>
				</div>
   			</div>
   			
   			<div class="layui-inline">
   				<label class="layui-form-label">开始时间</label>
    			<div class="layui-input-inline">
      				<input type="text" name="startTime" id="startTime" readonly="readonly" placeholder="yyyy-MM-dd HH-mm-ss"  class="layui-input">
    			</div>
   			</div>
   			
   			<div class="layui-inline">
   				<label class="layui-form-label">结束时间</label>
    			<div class="layui-input-inline">
      				<input type="text" name="endTime" id="endTime" readonly="readonly" placeholder="yyyy-MM-dd HH-mm-ss"  class="layui-input">
    			</div>
   			</div>
   			</div>
   				
   			<div class="layui-form-item" align="center">
   			<div class="layui-inline">
    			<div class="layui-input-inline">
      				 <button class="layui-btn" lay-submit="" lay-filter="search"  id="search"><span class="layui-icon layui-icon-search"></span>搜索</button>
      				 <button type="reset" class="layui-btn layui-btn-primary"><span class="layui-icon layui-icon-refresh-1"></span>重置</button>
    			</div>
   			</div>	
   			
   			</div>
   			
   		</form>
 	 </div>
</fieldset>
	<table id="salesback" lay-filter="salesback"></table>

<script type="text/javascript" src="/resources/layui/layui.js"></script>
<script type="text/javascript">
	var t;
	var selectTree;
	layui.use(["jquery","layer","form","table","laydate"],function(){
		var $ = layui.jquery;
		var layer = layui.layer;	
		var form = layui.form;	
		var table = layui.table;
		var upload = layui.upload;
		var laydate = layui.laydate;
		laydate.render({
			elem:'#startTime',
			type:'datetime'
		})
		laydate.render({
			elem:'#endTime',
			type:'datetime'
		})
		//table 初始化开始
		t = table.render({
			elem:"#salesback",
			page:true,
			url:"/buss/salesback/list",
			height: 'full-220',
			toolbar: true,
			parseData:function(rs){
				if(rs.code != 200){
					layer.msg(rs.msg);
					return false;
				}
				 return {
				      "code": rs.code, //解析接口状态
				      "msg": rs.msg, //解析提示文本
				      "count": rs.data.count, //解析数据长度
				      "data": rs.data.data //解析数据列表
				    };
			},
			response:{
				statusCode: 200 
			},
			cols:[ [
				 {field: 'id', title: '进货ID', sort: true,align:"center",width:"100"},
				 {field: 'customername', title: '客户名称', sort: true,align:"center",width:"150"},
				 {field: 'goodsname', title: '商品名称', sort: true,align:"center",width:"100"},
			     {field: 'size', title: '规格',align:"center",width:"100"},
			     {field: 'paytype', title: '支付类型',align:"center",width:"100"},
			     {field: 'salesbacktime', title: '退货时间', sort: true,align:"center",width:"150"},
				 {field: 'operateperson', title: '操作员', sort: true,align:"center",width:"100"},
			     {field: 'number', title: '退货数量',align:"center",width:"100"},
			     {field: 'salebackprice', title: '退货价格', sort: true,align:"center",width:"100"},
			     {field: 'remark', title: '退货备注',align:"center",width:"200"}
			] ]
		});
		
		//table 初始化结束
		form.on("submit(search)",function(d){
			t.reload({
				where:d.field,
				page:{
					curr:1
				}
			});	
			return false;
		});
		
		//初始客户下拉框
		$.post("/buss/sales/getCustomer",function(rs){
			var customer = rs.data;
			console.log(customer);
			$.each(customer,function(index,value){
				$("#customerid").append("<option value="+value.id+">"+ value.customername +"</option>");
			});
			form.render("select");
		})
		
		
	//初始商品化下拉框
		$.post("/buss/goods/getGoods",function(rs){
			var goods = rs.data;
			console.log(goods);
			$.each(goods,function(index,value){
				$("#goodsid").append("<option value="+ value.id +">"+ value.goodsname +"-"+value.size+"</option>");
			});
			form.render("select");
		})
	});
</script>
</body>
</html>